//
//  RequestManage.m
//  testToolDemo
//
//  Created by 段贤才 on 16/7/4.
//  Copyright © 2016年 volientDuan. All rights reserved.
//

#import "RequestManage.h"

// YES是生产环境 NO是测试环境
#define off NO
#define baseUrl off?@"":@"http://192.168.1.200:8834/"

@implementation RequestManage

+ (AFHTTPSessionManager *)shareHTTPManage{
    static AFHTTPSessionManager *manager = nil;
    static dispatch_once_t onceSession;
    dispatch_once(&onceSession, ^{
        manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:baseUrl]];
        manager.responseSerializer = [AFJSONResponseSerializer serializer];
        manager.requestSerializer.timeoutInterval = 12;
        manager.responseSerializer.acceptableContentTypes=[NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
    });
    if ([UserInfo sharedManage].token)
    {
        [manager.requestSerializer setValue:@"application/json"  forHTTPHeaderField:@"Accept"];
        [manager.requestSerializer setValue:[NSString stringWithFormat:@"Bearer %@", [UserInfo sharedManage].token] forHTTPHeaderField:@"Authorization"];
    }
    return manager;
}

+ (AFURLSessionManager *)shareTaskManage
{
    NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
    return [[AFURLSessionManager alloc]initWithSessionConfiguration:config];
}

@end
